package com.hw.one.collect.xinxiang.dao;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * Copyright 2017 汉威.智慧环保事业部.
 * Created by 李亚坤 on 2017/05/17 09:47.
 */
@Repository
public class SncodeDao {

    @Resource
    private JdbcTemplate jdbcTemplate;

    /**
     * 根据区域id查询该区域和该区域下所有的区域id,再根据这些id查询区域下的所有sncode
     * @param areaId
     * @return
     */
    public List<String> findSncodesByAreaId(String areaId) {

        String sql = "select sncode from tpoint p, "
                + "tgprsmodule g where p.id = g.id and ptype in (4) and p.areaid in (select id from tarea m "
                + "start with m.id = '"+areaId+"' connect by m.pid = prior m.id)";// 预编译语句，“？”代表参数
        List<String> sncodeList = jdbcTemplate.queryForList(sql, String.class);
        return sncodeList;
    }

}
